impl Solution {
    pub fn min_flips_mono_incr(s: String) -> i32 {
        let mut pre_fix=Vec::<i32>::with_capacity(s.len()+1);
        pre_fix.push(0);
        for c in s.as_bytes(){
            if c==&b'0'{
                pre_fix.push(*pre_fix.last().unwrap());
            }else{
                pre_fix.push(*pre_fix.last().unwrap()+1);
            }
        };
      
        let mut ans=1<<31-1;
        let mut last=0;
        for (i,c) in s.as_bytes().iter().enumerate().rev(){
            ans=ans.min(pre_fix[i]+last);
             if c==&b'0'{
                last+=1;
            }
            
        }
        ans
    }
}